/* Copyright (c) 2009 SpringShowcase, Inc.
 * All right reserved.
 * http://code.google.com/p/springshowcase/
 * This software is the confidential and proprietary information of BeyondWeb
 * , Inc. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license agreement
 * you entered into with BeyondWeb.
 *
 * Revision History
 * Author              Date             Description
 * ------------------   --------------    ------------------
 *  kwondohee           2010. 4. 2.        
 */
package org.springshowcase.mvc;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springshowcase.core.commons.config.Configuration;
import org.springshowcase.core.mvc.JsonView;

// TODO: Auto-generated Javadoc
/**
 * The Class FormTypeController.
 * 
 * @author kwondohee
 */
@Controller
@RequestMapping("/form")
public class FormTypeController {
	// ---------------------------------------------------------------------
	// Class Variable Declaration
	// ---------------------------------------------------------------------
	/** The Constant logger. */
	private static final Logger logger = LoggerFactory
			.getLogger(FormTypeController.class);

	/** The configuration. */
	@Autowired
	private Configuration configuration;

	// ---------------------------------------------------------------------
	// Constructor Method Declaration
	// ---------------------------------------------------------------------
	/**
	 * MVC controller.
	 */
	public FormTypeController() {
	}

	// ---------------------------------------------------------------------
	// DI Method (setter,getter) Declaration
	// ---------------------------------------------------------------------
	// ---------------------------------------------------------------------
	// this Method (public/private) Declaration
	// ---------------------------------------------------------------------
	/**
	 * Gets the add form success.
	 * 
	 * @return the add form success
	 */
	@RequestMapping(value = "/addFormSuccess")
	public ModelAndView getAddFormSuccess() {
		return new ModelAndView();
	}

	/**
	 * Gets the ajax object view.
	 * 
	 * @return the ajax object view
	 */
	@RequestMapping(value = "/ajaxObjectView")
	public ModelAndView getAjaxObjectView() {
		return new ModelAndView();
	}

	/**
	 * Gets the ajax query object.
	 * 
	 * @param model the model
	 * @return the ajax query object
	 */
	@RequestMapping(value = "/ajaxQueryObject")
	public ModelAndView getAjaxQueryObject(ModelMap model) {
		User user = new User();
		user.setId("springshowcase");
		user.setName("taeki.kim");
		user.setEmail("springorg@gmail.com");
		model.addAttribute(JsonView.CONTENT_OBJECT, user);
		return new ModelAndView();
	}

	/**
	 * Gets the ajax object list.
	 * 
	 * @return the ajax object list
	 */
	@RequestMapping(value = "/ajaxObjectList")
	public ModelAndView getAjaxObjectList() {
		return new ModelAndView();
	}

	/**
	 * Gets the ajax query list.
	 * 
	 * @param model the model
	 * @return the ajax query list
	 */
	@RequestMapping(value = "/ajaxQueryList")
	public ModelAndView getAjaxQueryList(ModelMap model) {
		List userList = new ArrayList();

		User user1 = new User();
		user1.setId("springshowcase1");
		user1.setName("taeki.kim");
		user1.setEmail("springorg@gmail.com");

		User user2 = new User();
		user2.setId("springshowcase2");
		user2.setName("sungwon.kim");
		user2.setEmail("sungwon@gmail.com");

		userList.add(user1);
		userList.add(user2);

		model.addAttribute(JsonView.CONTENT_OBJECT, userList);

		return new ModelAndView();
	}

	/**
	 * Gets the locale.
	 * 
	 * @return the locale
	 */
	@RequestMapping(value = "/locale")
	public ModelAndView getLocale() {
		return new ModelAndView();
	}

	@RequestMapping(value = "/forceAjaxExcption")
	public ModelAndView getForceAjaxExcption(
			@RequestParam(value = "exception", required = false) String exception) {
		// 강제로 exception을 발생 시킨다.
		if (!StringUtils.isEmpty(exception)) {
			String str = null;
			str.indexOf(".");
		}
		return new ModelAndView();
	}

	/**
	 * Gets the force form excption.
	 * 
	 * @return the force form excption
	 */
	@RequestMapping(value = "/forceFormExcption")
	public ModelAndView getForceFormExcption(
			@RequestParam(value = "exception", required = false) String exception) {
		// 강제로 exception을 발생 시킨다.
		if (!StringUtils.isEmpty(exception)) {
			String str = null;
			str.indexOf(".");
		}
		return new ModelAndView();
	}

	// ---------------------------------------------------------------------
	// interface implement Method (public/private) Declaration
	// ---------------------------------------------------------------------
	// ---------------------------------------------------------------------
	// abstract implement Method (public/private) Declaration
	// ---------------------------------------------------------------------
	// ---------------------------------------------------------------------
	// abstract Method (public/private) Declaration
	// ---------------------------------------------------------------------

}
